#pragma once

#include <vector>
#include <list>
#include "Physics.h"

using namespace std;

class GameObject; 

enum ObjectBuckets {TILES, STATIC_OBJECTS, GAMEOBJECTS, NOCOLLISION, PLAYER};

class ObjectManager
{
	//NOTE: Bucket 0: (Background) tiles
	//		Bucket 1: Static Objects
	//		Bucket 2: GameObjects
	//		Bucket 3: Objects with no Collision 
	//		Bucket 4: Player 
	vector<list<GameObject*>> objectTable;
private:
	ObjectManager(void);
	~ObjectManager(void);
	ObjectManager(const ObjectManager&);
	ObjectManager& operator=(const ObjectManager&);

	//////////////////////////////////////////////////////////
	// Static pointer to the singleton object
	static ObjectManager* pInstance;

	//
	//friend bool Physics::LineCast(LinecastInfo linecastInfo, float distance, tVector2D StartingPoint,tVector2D direction);

public:
	//////////////////////////////////////////////////////////
	// Singleton accessors:
	static ObjectManager* GetInstance( void );
	static void DeleteInstance( void );


	void UpdateAll(float deltaTime);
	void RenderAll() const;

	void CheckAllCollisions();
	void CheckCollision(GameObject& objToCheck, int bucket);
	void CheckCollision(GameObject& objectToCheck, GameObject& other);

	//Check one object against all objects in a bucket
	//CollisionInfo& GetCollisionInfo(GameObject& objectToCheck, int bucketToCheck);

	void AddObject(int bucket, GameObject* objToAdd);
	void RemoveAll();
	void RemoveAllExceptPlayer();

	const list<GameObject*> * GetBucket(int bucketToGet) const;

	//Store all of the check point objects once we hit the checkpoint
	void StoreCheckPointData();
};

